package net.chenlin.dp.modules.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.modules.business.entity.dto.DeviceDto;
import net.chenlin.dp.modules.business.entity.vo.device.Device;
import net.chenlin.dp.modules.business.service.TerminalDeviceManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Yangsm
 * @ClassName: TerminalDeviceManage
 * @Description: 终端设备管理
 * @date 2022年10月13日 14:57
 */
@Slf4j
@RestController
@RequestMapping("/terminalDevice")
@Api(tags = "终端设备管理")
public class DeviceManageController {

    @Autowired
    private TerminalDeviceManageService terminalDeviceManageService;

    @RequestMapping(value = "/getOnlneList", method = RequestMethod.POST)
    @ApiOperation(value = "展示在线设备的列表")
    public Page<Device> getTerminalList(@RequestBody Map<String, Object> params) {
        return terminalDeviceManageService.getTerminalList(params);
    }

    @RequestMapping(value = "/getDeviceList", method = RequestMethod.GET)
    @ApiOperation(value = "APP根据设备编号获取设备信息")
    public R getDeviceList(String deviceNo) {
        return terminalDeviceManageService.getDeviceInfo(deviceNo);
    }

    @RequestMapping(value = "/createDevice", method = RequestMethod.POST)
    @ApiOperation(value = "新建设备信息")
    public R createDevice(@RequestBody DeviceDto dto) {
        return terminalDeviceManageService.createDevice(dto);
    }

    @RequestMapping(value = "/editDevice", method = RequestMethod.POST)
    @ApiOperation(value = "编辑设备信息")
    public R editDevice(@RequestBody DeviceDto dto) {
        return terminalDeviceManageService.editDevice(dto);
    }

    @RequestMapping(value = "/getDevice", method = RequestMethod.GET)
    @ApiOperation(value = "查看设备信息")
    public R getDevice(Long id) {
        return terminalDeviceManageService.getDevice(id);
    }

    @RequestMapping(value = "/deleteDevice", method = RequestMethod.GET)
    @ApiOperation(value = "删除设备信息")
    public R deleteDevice(Long id) {
        return terminalDeviceManageService.deleteDevice(id);
    }
}
